﻿<UserControl x:Class="DaphneControls.GameLibraryControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:vm="clr-namespace:DaphneControls.ViewModel"
             xmlns:loc="http://schemas.tomer.com/winfx/2006/xaml/presentation"            
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.DataContext>
        <vm:GameLibraryControlVM />
    </UserControl.DataContext>    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="30" />
        </Grid.RowDefinitions>
        <ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Auto" Grid.Row="0">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="35" />
                </Grid.ColumnDefinitions>
                <DataGrid Grid.Column="0" x:Name="uxPDNGameList" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="True"
                          CanUserResizeColumns="True" CanUserResizeRows="False" ItemsSource="{Binding Path=Games}"
                           SelectedItem="{Binding Path=SelectedGameRecord, Mode=TwoWay}" 
                          SelectionMode="Single" SelectionUnit="FullRow">
                    <DataGrid.ColumnHeaderStyle>
                        <Style TargetType="{x:Type DataGridColumnHeader}">
                            <Style.Setters>
                                <Setter Property="ContentTemplate">
                                    <Setter.Value>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal">
                                                <TextBlock Text="{TemplateBinding Content}" Margin="3" VerticalAlignment="Center" />
                                                <Button x:Name="btnDel" Margin="3" Command="{Binding RelativeSource={RelativeSource FindAncestor, 
                                                             AncestorType={x:Type UserControl}}, Path=DataContext.DeleteTag}"
                                                        CommandParameter="{Binding}">
                                                    <Image Source="{Binding RelativeSource={RelativeSource FindAncestor, 
                                                                AncestorType={x:Type UserControl}}, Path=DataContext.DeleteImage}" 
                                                           Width="15" Height="15"  />
                                                </Button>
                                            </StackPanel>
                                        </DataTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style.Setters>
                        </Style>
                    </DataGrid.ColumnHeaderStyle>           
                </DataGrid>            
        
                <Button x:Name="btnAdd" Grid.Column="1" VerticalAlignment="Top" Command="{Binding Path=AddTag}" CommandParameter="{Binding ElementName=btnAdd}" >
                    <Image Source="{Binding Path=AddImage}" />
                </Button>
            </Grid>
        </ScrollViewer>
        <ToolBar Grid.Row="1">
            <Button loc:Translate.Uid="glOpen" Content="{loc:Translate Default=Open}" Width="100" Margin="3" Command="{Binding Path=OpenCommand}"/>
        </ToolBar>
    </Grid>
</UserControl>
